cc.Class({
    extends: cc.Component,

    properties: {

        _root_view: {
            type: fgui.GComponent,
            default: null,
        },

        _integral_view: fgui.GLabel,

        // digWin: Window,

    },

    // use this for initialization
    onLoad: function () {
        fgui.addLoadHandler();

        fgui.GRoot.create();

        fgui.UIPackage.loadPackage("UI/IMGame", this.onUILoaded.bind(this));

        //播放背景音乐
        // audiomg
    },

    onUILoaded: function () {
        // fgui.UIPackage.addPackage("UI/IMGame");

        _root_view = fgui.UIPackage.createObject("IMGame", "StartPanel").asCom;

        _root_view.makeFullScreen();

        this.loadRootUI();

    },

    loadRootUI: function () {
        //积分
        _integral_view = _root_view.getChild("n16").asLabel;

        _root_view.getChild("n7").onClick(this.onSetClick, this);
        _root_view.getChild("n8").onClick(this.onPlayClick, this);

        _root_view.getChild("n20").onClick(this.onPropClick, this);
        _root_view.getChild("n21").onClick(this.onStickClick, this);
        _root_view.getChild("n22").onClick(this.onRankClick, this);
        _root_view.getChild("n23").onClick(this.onGigtClick, this);
        // _root_view.getChild("n19").onClick(this.onStickClick, this);

        fgui.GRoot.inst.addChild(_root_view);
    },


    // called every frame
    update: function (dt) {

    },


    //设置按钮点击
    onSetClick: function () {
        console.log("hello world");
        // _root_view.Dispose();
        // cc.director.loadScene("resurrection");
        // var num = _integral_view.text;
        // _integral_view.text = ++num + "";

        // this.showDialog();

    },

    showDialog: function () {
        digWin = new Window();
        digWin.contentPane = UIPackage.CreateObject("IMGame", "RankDialog").asCom;
        digWin.Show();
    },

    //开始按钮点击
    onPlayClick: function () {
        //加载游戏场景
        cc.director.loadScene("game");
    },

    //道具按钮点击
    onPropClick: function () {
        var num = _integral_view.text;
        _integral_view.text = num++;
    },

    //箭按钮点击
    onStickClick: function () {
        console.log("hello world  stick");
    },

    //排行按钮点击
    onRankClick: function () {
        console.log("hello world  rank");
        this.showDialog();

    },

    //礼物按钮点击
    onGigtClick: function () {

    },
});
